<template>
  <CommonCard title="今日销售额" :value="numberFormat(salesToday)">
    <div class="compare-wrap">
      <div class="compare">
        <span>日同比</span>
        <span class="emphasis">{{ salesGrowthLastDay }}%</span>
        <span class="decrement"></span>
      </div>
      <div class="compare">
        <span>月同比</span>
        <span class="emphasis">{{ salesGrowthLastMonth }}%</span>
        <span class="increment"></span>
      </div>
    </div>
    <template #footer>
      <span>昨日销售额</span>
      <span class="emphasis">{{ moneyFormat(salesLastDay) }}</span>
    </template>
  </CommonCard>
</template>

<script lang="ts">
import CommonCard from "./CommonCard.vue"
export default {
  name: "TodaySales",
  components: { CommonCard },
}
</script>
<script lang="ts" setup>
import { ref, onMounted, computed } from "vue"
import { useReportDataStore } from "@/stores/reportData"
import { formatData } from "@/hooks/useFormat"
const reportDataStore = useReportDataStore()
const { numberFormat, moneyFormat } = formatData()

// 要渲染的数据
const salesToday = computed(() => reportDataStore.reportData.salesToday)
const salesLastDay = computed(() => reportDataStore.reportData.salesLastDay)
const salesGrowthLastDay = computed(
  () => reportDataStore.reportData.salesGrowthLastDay
)
const salesGrowthLastMonth = computed(
  () => reportDataStore.reportData.salesGrowthLastMonth
)
</script>

<style lang="scss" scoped>
.compare-wrap {
  height: 100%;
  font-size: 12px;
  font-weight: 700;
  color: #666;
  display: flex;
  flex-direction: column;
  .compare {
    flex: 1;
    display: flex;
    align-items: center;
  }
}
</style>
